﻿package config
{
	import base.BaseGameScene;
	
	import com.dusk.util.TimeUtil;
	import com.game.ctrler.BattleCamera;
	import com.game.ctrler.GameKeyInput;
	import com.game.data.vo.DebugParamVO;
	import com.game.data.vo.EquipmentVO;
	import com.game.data.vo.HeroGroupVO;
	import com.game.data.vo.KeyConfigVO;
	import com.game.data.vo.PlayerDataVO;
	import com.game.data.vo.UserDataVO;
	import com.game.engine.PhysicsWorld;
	import com.game.event.EventDispatchCenter;
	import com.game.manager.ConfigManager;
	import com.game.manager.EventManager;
	import com.game.manager.GameSceneManager;
	import com.game.manager.NotificationManager;
	import com.game.module.backpack.vo.BackPackEvent;
	import com.game.proxy.EquipProxy;
	import com.game.module.gameTask.GameTask;
	import com.game.module.heroBuff.view.SavedBuff;
	import com.game.proxy.GameProcessProxy;
	import com.game.proxy.SkillProxy;
	import com.game.proxy.UserDataProxy;
	import com.game.view.component.FloorBg;
	import com.game.view.layer.GameInfo;
	
	import export.FlowerSoul;
	
	import flash.geom.Point;
	
	public class Config
	{
		RegisterConfig;
		
		private static var _instance:Config;
		
		public static function getIns():Config
		{
			return _instance;
		}
		
		public function Config()
		{
			eventManager = new EventDispatchCenter();
			allEquip = new EquipProxy();
			allTask = new GameTask();
			configManager = new ConfigManager();
			
			if (!_instance)
			{
				_instance = this;
			}
		}
		
		public var configManager:ConfigManager;
		public var gameProcess:GameProcessProxy;
		public var memory:UserDataProxy;
		public var eventManager:EventDispatchCenter;
		public var isStopGame:Boolean = false;
		public var isInBattle:Boolean = false;
		public var allEquip:EquipProxy;
		public var isNew:Boolean;
		public var saveId:int = -1;
		public var curStage:uint = 1;
		public var curLevel:uint = 1;
		public var savedBuff:SavedBuff;
		public var heroBuffArray:Array = [];
		
		public var curDate:String;
		
		public var difficulty:uint;
		public var showHurtNum:Boolean = true;
		public var maxMonsterPerScreen:int = 8;
		public var maxFallObj:int = 50;
		
		
		public var playNum:int;
		public var userData:UserDataVO;
		public var keyConfig:KeyConfigVO;
		public var playerData:PlayerDataVO;
		public var allTask:GameTask;
		public var flowerSoul:FlowerSoul;
		
		/*-------------------战斗进行时才存在的变量-------------------*/
		public var gameScene:BaseGameScene;
		public var gameInfo:GameInfo;
		public var pWorld:PhysicsWorld;
		public var floorBackGround:FloorBg;
		public var team:HeroGroupVO;
		public var vController:BattleCamera;
		public var keyboardControl:GameKeyInput;
		/*-------------------战斗进行时才存在的变量-------------------*/
		
		public var debugParam:DebugParamVO = new DebugParamVO();
		
		public function initData():void
		{
			keyConfig = new KeyConfigVO();
			curDate = TimeUtil.getCurrentDate();
			saveId = -1;
			gameProcess = new GameProcessProxy();
			playerData = new PlayerDataVO();
			allTask.newAllTask();
			curStage = 1;
			curLevel = 1;
			difficulty = 0;
			showHurtNum = true;
			memory = new UserDataProxy();
			userData = new UserDataVO();
			//saved Buff = new SavedBuff();
			flowerSoul = new FlowerSoul();
		}
		
		public function get frameClips():int
		{
			return GameSceneManager.getIns().mainStage.frameRate;
		}
		
		public function set frameClips(rate:int):void
		{
			GameSceneManager.getIns().mainStage.frameRate = rate;
		}
		
		public function isSingleGame():Boolean
		{
			return true;
		}
		
		public function newGameClick():void
		{
			userData = new UserDataVO();
			curStage = 1;
			curLevel = 1;
			difficulty = 0;
			saveId = -1;
		}
		
		public function putQhsInBackPack(param1:PlayerDataVO, param2:String, param3:int = 1):void
		{
			param1.bagStuffList = putQHsInArray(param2, param1.bagStuffList, param3);
		}
		
		public function putQHsInArray(eqName:String, eqArray:Array = null, param3:int = 1):Array
		{
			var equipVO:EquipmentVO = null;
			for each (var item:EquipmentVO in eqArray)
			{
				if (item.equipId == eqName)
				{
					equipVO = item;
					break;
				}
			}
			if (equipVO != null)
			{
				equipVO.modifyNum(param3);
				EventManager.getIns().dispatchEvent(BackPackEvent.REFRESH_NUMBER);
			}
			else
			{
				equipVO = configManager.equipProxy.findByName(eqName);
				equipVO.num = param3;
				eqArray.push(equipVO);
			}
			return eqArray;
		}
		
		public function addGardenExp(param1:uint):void
		{
			if (userData.gardenLevel >= 9)
			{
				NotificationManager.alert("药园等级已满");
				userData.gardenExp = 999;
				return;
			}
			userData.gardenExp += param1;
			while (userData.gardenExp >= 1000)
			{
				userData.gardenExp -= 1000;
				userData.gardenLevel++;
			}
			NotificationManager.alert("种植经验提高了" + param1 + "点");
		}
		
		public function get needMMP():Array
		{
			return [[[10, 20, 32, 53, 75, 109, 139, 179, 228]/*升龙斩*/,
				[15, 23, 36, 61, 86, 113, 161, 207, 264]/*重斩*/,
				[0, 0, 0, 0, 0, 0, 0, 0, 0]/*嗜血*/,
				[26, 60, 105, 150, 195, 240, 285, 330, 375]/*七十二斩*/,
				[30, 72, 116, 164, 240, 300, 380, 450, 540, 600]/*火魔斩*/],
				[[9, 18, 40, 78, 106, 140, 195, 265, 310, 360]/*烈焰闪*/,
					[10, 20, 32, 53, 75, 109, 139, 179, 228]/*火焰突击*/,
					[18, 44, 72, 119, 168, 234, 313, 441, 600]/*烈焰风暴*/,
					[18, 40, 70, 100, 130, 160, 190, 220, 250]/*筋斗云*/,
					[30, 72, 116, 164, 240, 300, 380, 450, 540, 600]/*火眼金睛*/],
				[[10, 24, 40, 58, 80, 106, 138, 179, 230]/*圣光球*/,
					[20, 30, 76, 110, 164, 246, 344, 462, 600]/*沐浴回春*/,
					[15, 40, 80, 130, 185, 240, 290, 340, 400]/*紧箍咒*/,
					[20, 60, 160, 250, 330, 430, 520, 610, 700, 780]/*天降甘露*/,
					[30, 75, 135, 201, 282, 384, 511, 666, 876, 1146]/*九环圣经*/],
				[[12, 25, 38, 56, 78, 104, 136, 176, 226]/*冰龙波*/,
					[20, 69, 124, 186, 259, 346, 450, 579, 735]/*玄冰阵*/,
					[8, 15, 40, 70, 105, 140, 185, 235, 290]/*水幻影*/,
					[0, 0, 0, 0, 0, 0, 0, 0, 0]/*水精通*/,
					[30, 76, 149, 241, 344, 452, 591, 732, 870, 1000]/*水魔爆*/],
				[[10, 24, 40, 58, 80, 106, 138, 179, 228]/*盾击*/,
					[10, 27, 47, 81, 128, 180, 233, 300, 380]/*圣盾*/,
					[0, 0, 0, 0, 0, 0, 0, 0, 0]/*刃甲*/,
					[10, 33, 67, 103, 159, 208, 260, 314, 360]/*战争怒吼*/,
					[20, 69, 124, 186, 259, 346, 450, 579, 735, 904]/*圣域之墙*/],
				[[12, 25, 38, 55, 72, 95, 124, 162, 208]/*碎石破*/,
					[18, 35, 69, 103, 144, 190, 220, 250, 280, 300]/*巨石破*/,
					[16, 33, 67, 103, 152, 208, 259, 315, 372]/*地滚球*/,
					[24, 56, 106, 164, 229, 307, 398, 511, 646]/*旋滚球*/,
					[30, 72, 150, 231, 338, 430, 520, 620, 700, 820]/*土魔刺*/],
				[[10, 20, 32, 53, 75, 109, 139, 179, 228]/*瘴气*/,
					[10, 27, 47, 81, 128, 189, 263, 351, 452, 500]/*麻痹药剂*/,
					[28, 60, 140, 200, 270, 330, 400, 500, 580, 700]/*巫毒娃娃*/,
					[25, 56, 106, 164, 229, 307, 398, 511, 646]/*剧毒阵*/,
					[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]/*猛毒素*/],
				[[10, 24, 40, 58, 80, 106, 138, 179, 230]/*强力击*/,
					[18, 44, 72, 119, 168, 234, 313, 441, 600]/*腾空击*/,
					[22, 56, 106, 164, 229, 307, 398, 511, 646]/*多重击*/,
					[17, 40, 70, 100, 130, 160, 190, 220, 250]/*绿叶标记*/,
					[28, 69, 116, 175, 263, 380, 496, 624, 760, 900]/*木魔舞*/]];
		}
	}
}
